//
//  TF_BackNetSelectCell.swift
//  TalkfunSDKDemo
//
//  Created by 邓盛明 on 2022/1/19.
//  Copyright © 2022 Talkfun. All rights reserved.
//

import UIKit

class TF_BackNetSelectCell: UITableViewCell {
    var bgView:UIView!
    var titleLab:UILabel!
    var Cellwidth:CGFloat!
   
    override func awakeFromNib() {
        super.awakeFromNib()
        // Initialization code
    }
    
    override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        self.bgView = UIView.init()
        self.bgView.layer.masksToBounds = true
        
        self.bgView.layer.cornerRadius = 4
        self.contentView.addSubview(self.bgView)
    
        
        self.titleLab = UILabel.init()
        self.titleLab.textColor = UIColor(red: 5/255.0, green: 211/255.0, blue:128/255.0 , alpha: 1.0)
        self.titleLab.font = UIFont.PingFang(size: 16)
 
        self.titleLab.textAlignment = .center
        self.bgView.addSubview(self.titleLab)
       
    }
    
    override func layoutSubviews() {
        super.layoutSubviews()
        
        self.bgView.frame = CGRect(x: 21, y: 0, width: self.Cellwidth-42, height: 40)
        
        self.titleLab.frame = CGRect(x: 0, y: 0, width: self.bgView.frame.size.width, height: 40)
    }
    func setNetSelectMdoel(_ model:TF_BackNetWorkModel) {
        if model.isSelect {
            self.bgView.backgroundColor = UIColor.white
            self.bgView.layer.borderWidth = 1.0
          
            self.bgView.layer.borderColor = UIColor(red: 65/255.0, green:150/255.0, blue:235/255.0, alpha:1.0).cgColor
            
            self.titleLab.textColor =  UIColor(red: 65/255.0, green:150/255.0, blue:235/255.0, alpha:1.0)
        } else {
            self.bgView.backgroundColor = UIColor.clear
            self.bgView.layer.borderWidth = 1.0;
            self.bgView.layer.borderColor = UIColor(red: 201/255.0, green: 211/255.0, blue: 221/255.0, alpha: 0.5).cgColor
            self.titleLab.textColor = UIColor(red: 20/255.0, green: 23/255.0, blue: 26/255.0, alpha: 0.5)
        }
    }
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)

        // Configure the view for the selected state
    }

}
